<?php
/**
 * Created by PhpStorm.
 * User: zhan
 * Date: 2018/8/7  17:10
 */
namespace app\pc\logic;
use think\Cache;
use think\Request;
use app\pc\validate\Member as MemberValidate;

class Member extends \app\pc\BaseModel
{
    //检测参数是否已传
    protected $ParameterDetection  = [
    	'personal_information' => ['passwd','name','mobile','city','gender','age','loan_amount','income','contact_information']
    ];

    //个人详情
    public function memberInfo(){
    	return db('member')->where(['id'=>$this->user['id']])->find();
    }

    //修改个人资料
    public function personal_information(){
    	$passwd = $this->requestData['passwd'];
    	if(!empty($passwd)){
    		$update['passwd'] = md5($passwd);
    	}
    	
    	$update['name'] = $this->requestData['name'];
    	$update['mobile'] = $this->requestData['mobile'];
    	$update['city'] = $this->requestData['city'];
    	$update['gender'] = $this->requestData['gender'];
        $update['age'] = $this->requestData['age'];
        $update['loan_amount'] = $this->requestData['loan_amount'];
    	$update['pay_method'] = $this->requestData['pay_method'];
    	
    	$update['income'] = $this->requestData['income'];
    	$update['contact_information'] = $this->requestData['contact_information'];

    	$update=array_filter($update);
    	db('member')->where(['id'=>$this->user['id']])->update($update);
    }
}